﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Text.RegularExpressions;
/// <summary>
/// Summary description for Ask_And_Answer
/// </summary>
public class Ask_And_Answer
{
    public static bool Ask(string question, string username)
    {
        using (SWE2Entities db = new SWE2Entities())
        {

            Question_Table q = new Question_Table();
            if (string.IsNullOrEmpty(question) || string.IsNullOrEmpty(username))
            {
                return false;

                //    return true;

            }



            else
            {

                q.Question = question;
                q.Username = username;
                db.Question_Table.Add(q);
                db.SaveChanges();
                return true;
            }


        }


    }


    public static bool Answer(int ID, string answer, string username)
    {
       using (SWE2Entities db=new SWE2Entities())
       {
           Answer_Table ans = new Answer_Table();

           if (string.IsNullOrEmpty(answer) || string.IsNullOrEmpty(username))
           {
               return false;

               //    return true;

           }



           else
           {
               ans.ID = ID;
               ans.Answer = answer;
               ans.Username =username;
               db.SaveChanges();
               return true;
           }

       }


    }





}